import React, { Component } from 'react';
import {
  StyleSheet,
  Text,
  View,
  Image,
  ScrollView,
  TouchableOpacity,
  DeviceEventEmitter,
  Platform,
  Dimensions,
  NativeAppEventEmitter
} from 'react-native';

import styles from './orderDetailStyle';
import ProgressBar from '../global/ProgressBar';
import helper from '../util/helper';
import api from '../../services/api';
import Toast from 'react-native-sk-toast';
import Communications from 'react-native-communications';
import AMap from '../global/amapView/AMap';
import moment from 'moment';
import RNFetchBlob from 'rn-fetch-blob';
import _ from 'lodash';

import * as config from '../../constants/apiConfig';
import LoadingTip from '../global/LoadingTip';
import ToastTip from '../global/ToastTip';
import DeviceStorage from '../global/DeviceStorage';
import { Navigation } from '../global/navigation/index';

const {width: deviceWidth, height: deviceHeight} = Dimensions.get('window');

class OrderConfirm extends Component {
    constructor(props) {
		super(props);
        this.state = {
            showLoading: false,
            submitDisabled: false,
		};

        this.serviceTypeMap = {
            'send': {'m':this._renderSend.bind(this),'index':0},
            'buy': {'m':this._renderBuy.bind(this),'index':1},
            'express': {'m':this._renderExpress.bind(this),'index':2},
            'lockkey': {'m':this._renderLockkey.bind(this),'index':3},
            'other': {'m':this._renderOhter.bind(this),'index':4},
            'nursing':{'m':this._renderNursing.bind(this),'index':5}
        }

	}

    componentWillMount() {
		// this._retrieveDetails();
        // this._onRefresh();
    }

    _onRefresh(){


    }

    _onNavigatorEvent(event) {

        // console.log(event);
	}

    componentDidMount(){
        // this._searchRidingRoute();
        // this._onRefresh();
    }

    componentWillUnmount() {
        // let {actions, dispatch} = this.props;
        // dispatch(actions.order.order_clear_cardobj());
        // this.detailSubcribe && this.detailSubcribe.remove();
    }

    componentWillReceiveProps(nextProps) {

    }

    chooseType = (type) => {
        switch (type) {
            case "other":
                return  "其他"
            case "report":
                return  "报事"
            case "repair":
                return "报修"
            case "shops":
                return "特权"
            case "activity":
                return "活动报名"
            default:
               return  "预约办理"
        }
    }

    _readFileToBase64(info){
        this.setState({showLoading:true, submitDisabled: true});
        let {fileUri} = this.props;
        if (fileUri) {
            let data = ''
            RNFetchBlob.fs.readStream(
                // file path
                fileUri,
                // encoding, should be one of `base64`, `utf8`, `ascii`
                'base64',
                // (optional) buffer size, default to 4096 (4095 for BASE64 encoded data)
                // when reading file in BASE64 encoding, buffer size must be multiples of 3.
                4095)
            .then((ifstream) => {
                ifstream.open()
                ifstream.onData((chunk) => {
                  // when encoding is `ascii`, chunk will be an array contains numbers
                  // otherwise it will be a string
                  data += chunk
                })
                ifstream.onError((err) => {
                  console.log('oops', err)
                  this.setState({showLoading:false, submitDisabled: false});
                  return;
                })
                ifstream.onEnd(() => {  
                    data = "data:image/jpeg;base64,"+data;
                    info = {...info,remarkImage:data}
                    // if (serviceFee&&serviceFee.id) {
                    //     info = {...info,remarkImage:data,serviceFeeId:serviceFee.id}
                    //     info.status = 0;
                    // }else{
                    //     info = {...info,remarkImage:data}
                    // }
                    let {service_type} = info;
                    if (service_type == "nursing") {//护理服务在生成订单之前需要设置服务费

                        let {serviceFee} = this.props;
                        console.log('serviceFee==============',serviceFee);
                        if (serviceFee&&serviceFee.length > 0) {

                            let orderFeeList = [];
                            
                            serviceFee.map((item,index)=>{
                                orderFeeList.push({feeId:item.id,feeName:item.serviceFeeName,feeAmount:parseFloat(item.fee)})
                            })
                            console.log('serviceFee==============',orderFeeList);



                            info = {...info,orderFeeList}
                            console.log('serviceFee==============info',info);
                            let {ownerInfo} = info
                            if (ownerInfo && ownerInfo.isVip == 1 && ownerInfo.keeperServiceLeftCount > 0) {
                                info.status = 1;
                            }else{
                                info.status = 0;
                            }

                        }

                        this.props.navigator.push({
                            title: '设置金额',
                            screen: 'housekeeperapp.nursingservicecompletion',
                            backButtonTitle:'',
                            passProps: {
                                order_info: {...info}
                            },
                            navigatorStyle:{
                                tabBarHidden: true,
                                navBarTextColor: 'white',
                                navBarButtonColor: 'white',
                                statusBarColor: '#EA5404',
                                navBarBackgroundColor: '#EA5404',
                                navBarTitleTextCentered: true
                            },
                            navigatorButtons: {
                                leftButtons:[
                                    {
                                        id: 'back',
                                        icon: require("../../../img/hk_back_icon.png")
                                    }
                                ]
                            }
                        });
                        this.setState({showLoading:false, submitDisabled: false});
                        return;
                    }
                    this._getComplete(info,true);
                })
            })
        }else{
            info = {...info,remarkImage:''};
            // if (serviceFee&&serviceFee.id) {
            //     info = {...info,remarkImage:'',serviceFeeId:serviceFee.id};
            //     info.status = 0;
            // }else{
            //     info = {...info,remarkImage:''};
            // }
            
            let {service_type} = info;
            if (service_type == "nursing") {//护理服务在生成订单之前需要设置服务费
                let {serviceFee} = this.props;
                if (serviceFee&&serviceFee.id) {
                    info = {...info,serviceFeeId:serviceFee.id}
                    info.status = 0;
                }
                this.props.navigator.push({
                    title: '设置金额',
                    screen: 'housekeeperapp.nursingservicecompletion',
                    backButtonTitle:'',
                    passProps: {
                        order_info: {...info}
                    },
                    navigatorStyle:{
                        tabBarHidden: true,
                        navBarTextColor: 'white',
                        navBarButtonColor: 'white',
                        statusBarColor: '#EA5404',
                        navBarBackgroundColor: '#EA5404',
                        navBarTitleTextCentered: true
                    },
                    navigatorButtons: {
                        leftButtons:[
                            {
                                id: 'back',
                                icon: require("../../../img/hk_back_icon.png")
                            }
                        ]
                    }
                });
                this.setState({showLoading:false, submitDisabled: false});
                return;
            }
            this._getComplete(info,true);
        }
        
    }

    async _getComplete(info,isLoading){

        if (isLoading) {
            
        }else{
            this.setState({showLoading:true, submitDisabled: true});
        }

        // let order = this.props.order_detail;
        // if (order.service_type == 'express') {
        let {serviceFee} = this.props;
        console.log('serviceFee==============',serviceFee);
        if (serviceFee&&serviceFee.length > 0) {

            let orderFeeList = [];
            
            serviceFee.map((item,index)=>{
                orderFeeList.push({feeId:item.id,feeName:item.serviceFeeName,feeAmount:parseFloat(item.fee)})
            })
            console.log('serviceFee==============',orderFeeList);



            info = {...info,orderFeeList}
            console.log('serviceFee==============info',info);
            let {ownerInfo} = info
            if (ownerInfo && ownerInfo.isVip == 1 && ownerInfo.keeperServiceLeftCount > 0) {
                info.status = 1;
            }else{
                info.status = 0;
            }
            

        }
        // }
        
        

        

        let copyInfo = {...info};

        console.log('test---------------------create',copyInfo);
        let res = await api.post('/order/createorder',copyInfo);

        if(res.cd == 1){
            this.setState({showLoading:false, submitDisabled: false});
            this.refs.toast.show(res.msg, 3000);
            return;
        }

        // 清空地址信息
        let { session , actions, dispatch} = this.props;
        let action;
        if(copyInfo.service_type == 'send'){
            action = actions.order.order_clearaddress();
            await dispatch(action);
        }else if (copyInfo.service_type == 'buy'){
            action = actions.order.order_clearbuyaddress();
            await dispatch(action);
        }

        DeviceStorage.delete("@order@"+copyInfo.service_type);

        let ownerInfo = await api.post('/account/findUserByPhone',{phone: copyInfo.user_phone});
        let content = "";
        // if(copyInfo.service_type == "express" || copyInfo.service_type == "lockkey"){
        //     content = "您的"+ (copyInfo.service_type == "express"?"代取快递":"保管钥匙") +"订单已确认。<a href='" + config.WEB_BASE_URL + "/housekeeper/orderdetail?id="+res.data.id+"'>查看详情</a>"
        // }else{
        //     content = "您的"+ (copyInfo.service_type == "other"?copyInfo.other_service_content:copyInfo.obj_name) +"订单已确认。<a href='" + config.WEB_BASE_URL + "/housekeeper/orderdetail?id="+res.data.id+"'>查看详情</a>";
        // }
        //
        // let json = JSON.stringify({
        //                 "touser":ownerInfo.data.wxOpenId,
        //                 "msgtype":"text",
        //                 "text":
        //                 {
        //                      "content": content,
        //                 }
        //             });
        //
        // let send_res = await api.post('/wx/customsend',{json});
        if(copyInfo.isThirdParty == 1 || (session.user.role == 1 && session.user.village)){
            Toast.bottom("订单已生成，请实时跟踪并更新订单状态");
        }else{
            Toast.bottom("提交成功");
        }

        setTimeout(async ()=>{
            let Emitter = Platform.OS === 'android' ? DeviceEventEmitter : NativeAppEventEmitter;
            this.setState({showLoading:false, submitDisabled: false},() => {
                Emitter.emit("order.create_success");
                this.props.navigator.popToRoot();
                if(this.props.order_phone){//从消息直接添加订单过来
                    this.props.navigator.switchToTab({
                      tabIndex: 2
                    });
                }

                
                Emitter.emit("order.onload", copyInfo.service_type, "");
            });

        }, 100);

    }

    async _postExpressData(info){
        let copyInfo = {...info};


        let res = await api.post('/order/createorder',copyInfo);

        if(res.cd == 1){
            this.setState({showLoading:false, submitDisabled: true});
            this.refs.toast.show(res.msg, 3000);
            return;
        }

        // 清空地址信息
        let { session , actions, dispatch} = this.props;
        let action;
        if(copyInfo.service_type == 'send'){
            action = actions.order.order_clearaddress();
            await dispatch(action);
        }else if (copyInfo.service_type == 'buy'){
            action = actions.order.order_clearbuyaddress();
            await dispatch(action);
        }

        let ownerInfo = await api.post('/account/findUserByPhone',{phone: copyInfo.user_phone});
        let content = "";
        // if(copyInfo.service_type == "express" || copyInfo.service_type == "lockkey"){
        //     content = "您的"+ (copyInfo.service_type == "express"?"代取快递":"保管钥匙") +"订单已确认。<a href='" + config.WEB_BASE_URL + "/housekeeper/orderdetail?id="+res.data.id+"'>查看详情</a>"
        // }else{
        //     content = "您的"+ (copyInfo.service_type == "other"?copyInfo.other_service_content:copyInfo.obj_name) +"订单已确认。<a href='" + config.WEB_BASE_URL + "/housekeeper/orderdetail?id="+res.data.id+"'>查看详情</a>";
        // }
        //
        // let json = JSON.stringify({
        //                 "touser":ownerInfo.data.wxOpenId,
        //                 "msgtype":"text",
        //                 "text":
        //                 {
        //                      "content": content,
        //                 }
        //             });
        //
        // let send_res = await api.post('/wx/customsend',{json});
        if(copyInfo.isThirdParty == 1 || (session.user.role == 1 && session.user.village)){
            Toast.bottom("订单已生成，请实时跟踪并更新订单状态");
        }else{
            Toast.bottom("提交成功");
        }

        setTimeout(async ()=>{
            this.setState({showLoading:false, submitDisabled: true});
            this.props.navigator.popToRoot();
            if(this.props.order_phone){//从消息直接添加订单过来
                this.props.navigator.switchToTab({
                  tabIndex: 2
                });
            }

            let Emitter = Platform.OS === 'android' ? DeviceEventEmitter : NativeAppEventEmitter;
            Emitter.emit("order.onload", copyInfo.service_type, "");
        }, 100);
    }

    _back(){
        this.props.navigator.pop();
    }

    _clickImage(index){
        let {fileUri} = this.props;
        if (fileUri) {//有图片则预览
            this._previewPicture(fileUri)
            return;
        }
    }

    _previewPicture(fileUri){
        Navigation.startPreviewPictureActivity({"currentIndex":0,"fileUris":fileUri,"isUrl":true})
    }


    _renderSend(info){
        let {fileUri,isPay,serviceFee} = this.props;
        return (
             <View style={styles.sendContainer}>
                <View style={[styles.fPart, {paddingTop: 0}]}>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>寄</Text>
                        <Text style={[styles.objSubTitle,{flex:10}]}>{info.from_address}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>收</Text>
                        <Text style={[styles.objSubTitle,{flex:10}]}>{info.to_address}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务时间</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.service_time}</Text>
                    </View>
                    
                    {isPay && serviceFee && serviceFee.length > 0?
                        serviceFee.map((item , index) => {
                            return (
                                <View style={styles.objInfo}>
                                    <Text style={styles.objTitle}>{item.serviceFeeName}</Text>
                                    <Text style={[styles.objSubTitle, {flex:4}]}>¥{parseFloat(item.fee).toFixed(2)}</Text>
                                </View>
                            )
                        })
                        
                        :
                        null
                    }
                    

                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>备注</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.remarks?info.remarks:'无'}</Text>
                    </View>
                    {
                        fileUri?
                            <TouchableOpacity activeOpacity={0.7} onPress={this._clickImage.bind(this)}>
                                <Image source={{uri: fileUri}} resizeMode="contain" style={[styles.uploadAvatar,{marginTop:10}]}/>
                            </TouchableOpacity>
                        :
                        null
                    }
                </View>

                <View style={[styles.fPart,{marginTop:10,paddingTop: 0}]}>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>发件人</Text>
                        <Text style={[styles.objSubTitle,{flex:5}]}>{info.user_phone}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>收件人</Text>
                        <Text style={[styles.objSubTitle,{flex:5}]}>{info.phone}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>物品名称</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.obj_name}</Text>
                    </View>

                </View>
                {info.isThirdParty == 1?<View style={[styles.fPart,{marginTop:10,paddingTop: 0}]}>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务方</Text>
                        <Text style={[styles.objSubTitle,{flex:5}]}>{info.thirdPartyName}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务人员姓名</Text>
                        <Text style={[styles.objSubTitle,{flex:5}]}>{info.thirdPartyPerson?info.thirdPartyPerson:'无'}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务人员电话</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.thirdPartyPhone}</Text>
                    </View>
                </View>:null}

            </View>
        );
    }

    _renderBuy(info){
        let {fileUri,isPay,serviceFee} = this.props;
        return (
            <View style={styles.sendContainer}>

                   <View style={[styles.fPart, {paddingTop: 0}]}>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>购买物品</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.obj_name}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>购买地址</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.from_address?info.from_address:'无'}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>收货地址</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.to_address}</Text>
                    </View>


                    

                </View>

                <View style={[styles.fPart,{marginTop:10,paddingTop: 0}]}>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务时间</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.service_time}</Text>
                    </View>
                    {isPay && serviceFee && serviceFee.length > 0?
                        serviceFee.map((item , index) => {
                            return (
                                <View style={styles.objInfo} key={index}>
                                    <Text style={styles.objTitle}>{item.serviceFeeName}</Text>
                                    <Text style={[styles.objSubTitle, {flex:4}]}>¥{parseFloat(item.fee).toFixed(2)}</Text>
                                </View>
                            )
                        })
                        
                        :
                        null
                    }
                    


                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>收货人</Text>
                        <Text style={[styles.objSubTitle,{flex:5}]}>{info.user_phone}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>期望价格</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{parseFloat(info.obj_price).toFixed(2) + '元'}</Text>
                    </View>

                    

                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>备注</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.remarks?info.remarks:'无'}</Text>
                    </View>
                    {
                        fileUri?
                            <TouchableOpacity activeOpacity={0.7} onPress={this._clickImage.bind(this)}>
                                <Image source={{uri: fileUri}} resizeMode="contain" style={[styles.uploadAvatar,{marginTop:10}]}/>
                            </TouchableOpacity>
                        :
                        null
                    }

                </View>

                {info.isThirdParty == 1?<View style={[styles.fPart,{marginTop:10,paddingTop: 0}]}>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务方</Text>
                        <Text style={[styles.objSubTitle,{flex:5}]}>{info.thirdPartyName}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务人员姓名</Text>
                        <Text style={[styles.objSubTitle,{flex:5}]}>{info.thirdPartyPerson?info.thirdPartyPerson:'无'}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务人员电话</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.thirdPartyPhone}</Text>
                    </View>
                </View>:null}

            </View>
        );
    }

    _renderExpress(info){
        let {fileUri,isPay,serviceFee} = this.props;
        return (
             <View style={styles.sendContainer}>
                <View style={[styles.fPart, {paddingTop: 0}]}>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务内容</Text>
                        <Text style={[styles.objSubTitle, {flex:4}]}>{info.express_service_content}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务时间</Text>
                        <Text style={[styles.objSubTitle, {flex:4}]}>{info.service_time}</Text>
                    </View>

                    {isPay && serviceFee && serviceFee.length > 0?
                        serviceFee.map((item , index) => {
                            return (
                                <View style={styles.objInfo} key={index}>
                                    <Text style={styles.objTitle}>{item.serviceFeeName}</Text>
                                    <Text style={[styles.objSubTitle, {flex:4}]}>¥{parseFloat(item.fee).toFixed(2)}</Text>
                                </View>
                            )
                        })
                        
                        :
                        null
                    }
                    
                </View>

                <View style={[styles.fPart,{marginTop:10,paddingTop: 0}]}>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>收件人</Text>
                        <Text style={[styles.objSubTitle,{flex:5}]}>{info.user_phone}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>收件地址</Text>
                        <Text style={[styles.objSubTitle ,{flex:4}]}>{info.to_address}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>备注</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.remarks?info.remarks:'无'}</Text>
                    </View>
                    
                    {
                        fileUri?
                            <TouchableOpacity activeOpacity={0.7} onPress={this._clickImage.bind(this)}>
                                <Image source={{uri: fileUri}} resizeMode="contain" style={[styles.uploadAvatar,{marginTop:10}]}/>
                            </TouchableOpacity>
                        :
                        null
                    }
                </View>

            </View>
        );
    }

    _renderLockkey(info){
        let {fileUri} = this.props;
        return (
             <View style={styles.sendContainer}>
                <View style={[styles.fPart, {paddingTop: 0}]}>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务内容</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.lockkey_service_content}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务时间</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.service_time}</Text>
                    </View>

                </View>

                <View style={[styles.fPart,{marginTop:10,paddingTop: 0}]}>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>业主电话</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.user_phone}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务地址</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.to_address}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>备注</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.remarks?info.remarks:'无'}</Text>
                    </View>
                    {
                        fileUri?
                            <TouchableOpacity activeOpacity={0.7} onPress={this._clickImage.bind(this)}>
                                <Image source={{uri: fileUri}} resizeMode="contain" style={[styles.uploadAvatar,{marginTop:10}]}/>
                            </TouchableOpacity>
                        :
                        null
                    }
                </View>

            </View>
        );
    }

    _renderOhter(info){
        let {fileUri,isPay,serviceFee} = this.props;
        return (
            <View style={styles.sendContainer}>
                 <View style={[styles.fPart, {paddingTop: 4}]}>
                    <View style={[styles.objInfo,{paddingTop: 0}]}>
                        <Text style={styles.objTitle}>服务类型</Text>
                        <Text style={[styles.objSubTitle, {flex:4}]}>{this.chooseType(info.otherServiceType)}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务内容</Text>
                        <Text style={[styles.objSubTitle, {flex:4}]}>{info.other_service_content}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务时间</Text>
                        <Text style={[styles.objSubTitle, {flex:4}]}>{info.service_time}</Text>
                    </View>
                    {isPay && serviceFee && serviceFee.length > 0?
                        serviceFee.map((item , index) => {
                            return (
                                <View style={styles.objInfo} key={index}>
                                    <Text style={styles.objTitle}>{item.serviceFeeName}</Text>
                                    <Text style={[styles.objSubTitle, {flex:4}]}>¥{parseFloat(item.fee).toFixed(2)}</Text>
                                </View>
                            )
                        })
                        
                        :
                        null
                    }
                    

                </View>

                <View style={[styles.fPart,{marginTop:10,paddingTop: 4}]}>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务地址</Text>
                        <Text style={[styles.objSubTitle, {flex:4}]}>{info.to_address}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>业主电话</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.user_phone}</Text>
                    </View>
                </View>

                {
                    fileUri?
                        <TouchableOpacity activeOpacity={0.7} onPress={this._clickImage.bind(this)}>
                            <View  style={[styles.fPart,{marginTop:10,paddingTop: 4}]}>
                                <Image source={{uri: fileUri}} resizeMode="contain" style={[styles.uploadAvatar,{marginTop:10}]}/>
                            </View>
                        </TouchableOpacity>
                    :
                    null
                }

                {info.isThirdParty == 1?<View style={[styles.fPart,{marginTop:10,paddingTop: 0}]}>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务方</Text>
                        <Text style={[styles.objSubTitle,{flex:5}]}>{info.thirdPartyName}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务人员姓名</Text>
                        <Text style={[styles.objSubTitle,{flex:5}]}>{info.thirdPartyPerson?info.thirdPartyPerson:'无'}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务人员电话</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.thirdPartyPhone}</Text>
                    </View>
                </View>:null}

            </View>
        );
    }

    _renderNursing(info){
        let {fileUri,isPay,serviceFee} = this.props;
        return (
            <View style={styles.sendContainer}>
                 <View style={[styles.fPart, {paddingTop: 4}]}>
                    <View style={[styles.objInfo,{paddingTop: 0}]}>
                        <Text style={styles.objTitle}>服务类型</Text>
                        <Text style={[styles.objSubTitle, {flex:4}]}>护理服务</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务内容</Text>
                        <Text style={[styles.objSubTitle, {flex:4}]}>{info.other_service_content}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务时间</Text>
                        <Text style={[styles.objSubTitle, {flex:4}]}>{info.service_time}</Text>
                    </View>
                    {isPay && serviceFee && serviceFee.length > 0?
                        serviceFee.map((item , index) => {
                            return (
                                <View style={styles.objInfo} key={index}>
                                    <Text style={styles.objTitle}>{item.serviceFeeName}</Text>
                                    <Text style={[styles.objSubTitle, {flex:4}]}>¥{parseFloat(item.fee).toFixed(2)}</Text>
                                </View>
                            )
                        })
                        
                        :
                        null
                    }
                    

                </View>

                <View style={[styles.fPart,{marginTop:10,paddingTop: 4}]}>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务地址</Text>
                        <Text style={[styles.objSubTitle, {flex:4}]}>{info.to_address}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>用户电话</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.user_phone}</Text>
                    </View>
                </View>

                {
                    fileUri?
                        <TouchableOpacity activeOpacity={0.7} onPress={this._clickImage.bind(this)}>
                            <View  style={[styles.fPart,{marginTop:10,paddingTop: 4}]}>
                                <Image source={{uri: fileUri}} resizeMode="contain" style={[styles.uploadAvatar,{marginTop:10}]}/>
                            </View>
                        </TouchableOpacity>
                    :
                    null
                }

                {info.isThirdParty == 1?<View style={[styles.fPart,{marginTop:10,paddingTop: 0}]}>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务方</Text>
                        <Text style={[styles.objSubTitle,{flex:5}]}>{info.thirdPartyName}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务人员姓名</Text>
                        <Text style={[styles.objSubTitle,{flex:5}]}>{info.thirdPartyPerson?info.thirdPartyPerson:'无'}</Text>
                    </View>
                    <View style={styles.objInfo}>
                        <Text style={styles.objTitle}>服务人员电话</Text>
                        <Text style={[styles.objSubTitle,{flex:4}]}>{info.thirdPartyPhone}</Text>
                    </View>
                </View>:null}

            </View>
        );
    }

    render() {
        let order = this.props.order_detail;

        return (
            !order? <View style={styles.progressBar}><ProgressBar /></View> :
            <View style={styles.wrapper}>
                <ScrollView style={styles.container}>
                    <View style={styles.content}>
                        {this.serviceTypeMap[order.service_type]['m'](order)}
                    </View>
                </ScrollView>
                <View style={styles.actionBtnTowContainer}>
                    <TouchableOpacity style={styles.actionOneContainer} activeOpacity={0.7} onPress={this._back.bind(this)}>
                        <Text style={styles.actionOne}>返回修改</Text>
                    </TouchableOpacity>
                    <TouchableOpacity disabled={this.state.submitDisabled} style={styles.actionTowContainer} activeOpacity={0.7} onPress={order.service_type == 'express' ? this._getComplete.bind(this,order,false) :this._readFileToBase64.bind(this, order)}>
                        <Text style={styles.actionBtn}>确认提交</Text>
                    </TouchableOpacity>
                </View>
                <ToastTip ref="toast" offsetY={160}/>
                <LoadingTip show={this.state.showLoading}/>
            </View>
        );
    }
}

var connectHelper = require('../../services/connectHelper');
OrderConfirm = connectHelper(state => state)(OrderConfirm);

module.exports = OrderConfirm;
